﻿#include "FITKAcousticsAbsMaterial.h"

namespace Acoustics
{
    FITKAcousticsAbsMaterial::~FITKAcousticsAbsMaterial()
    {

    }

    FITKAcousticsAbsMaterial::AcousticsMaterialType FITKAcousticsAbsMaterial::getAcousticsMaterialType()
    {
        return FITKAcousticsAbsMaterial::AcousticsMaterialType::None;
    }

    double FITKAcousticsAbsMaterial::getDensity() const
    {
        return _density;
    }

    void FITKAcousticsAbsMaterial::setDensity(const double& density)
    {
        _density = density;
    }

    bool FITKAcousticsAbsMaterial::copy(Core::FITKAbstractDataObject *obj)
    {
        //转换强制类型
        Acoustics::FITKAcousticsAbsMaterial* data = dynamic_cast<Acoustics::FITKAcousticsAbsMaterial*>(obj);

        if(nullptr == data)//判断是否转换成功
        {
            return false;
        }

        //复制成员变量
        _density = data->getDensity();
        // 调用父类的方法
        Interface::FITKAbstractMaterial::copy(obj);
        return true;
    }

    void FITKAcousticsAbsMaterial::updateDefaultColor()
    {
    }

    QList<FITKAcousticsAbsMaterial*> FITKAcousticsMaterialManager::getAcousticsMaterials(
            FITKAcousticsAbsMaterial::AcousticsMaterialType t)
    {
        QList<FITKAcousticsAbsMaterial*> materials;
        const int n = this->getDataCount();
        for (int i =0;i < n; ++i)
        {
            FITKAcousticsAbsMaterial* m = dynamic_cast<FITKAcousticsAbsMaterial*>(this->getDataByIndex(i));
            if (m != nullptr && m->getAcousticsMaterialType() == t)
                materials.append(m);
        }
        return materials;
    }

}

